<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>

        <?php echo $this->Html->charset(); ?>

        <title>
            <?php echo $title_for_layout; ?>
        </title>

        <meta name="viewport" content="width=device-width, initial-scale =1.0">
            <meta name="keywords" content="Tattlr,Twitter,CoolSoft">
                <meta name ="author" content ="CoolSoft2012">

                    <?php
                    # Import javascript and css files.
                    echo $this->Html->script(array('jquery-1.7.2.min',
                        'jquery-ui-1.8.19.custom.min',
                        'bootstrap.min'));
                    echo $this->Html->css(array('bootstrap.min',
                        'jquery-ui-1.8.19.custom.css'));
                    echo $this->Html->meta('icon');

                    # Fetch the imported files.
                    echo $this->fetch('meta');
                    echo $this->fetch('css');
                    echo $this->fetch('script');
                    ?>

                    <!-- Le styles -->
                    <style type="text/css">
                        body {
                            padding-top: 60px;
                            padding-bottom: 40px;
                        }
                    </style>
<?php echo $this->Html->css('bootstrap.min'); ?>
                    </head>

                    <body>
                        <div class="navbar navbar-fixed-top">
                            <div class="navbar-inner">
                                <div class="container-fluid">
                                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                        <span class="icon-bar"></span>
                                        <span class="icon-bar"></span>
                                        <span class="icon-bar"></span>
                                    </a><!--btn-navbar-->
                                    <a class="brand" href="http://tattlr.com">Tattlr</a>
                                    <div class="nav-collapse">
                                        <ul class="nav">
                                            <li><a href="#" id = "dash"><i  class ="icon-home icon-white"></i> Dashboard</a></li>
                                            <li><a href="#" id="home">Home Timeline</a></li>
                                            <li><a href="#" id="followers">View followers</a></li>
                                            <li><a href="/Tweets">Search</a></li>
                                            <?php if (Configure::read('ad') == 0) { ?>
                                                <li><a href="/tasks/">Tasks</a></li>
                                            <?php } ?>      
                                            <li><a href="/FutureDms/">View DMs</a></li>
                                            <li><a href="/FutureTweets">FutureTweets</a></li>
                                            <li><a href="/events">Events</a></li>

                                            <?php if ($ad == 1) { ?>
                                                <li><a href="/tattlraccounts/">Admin</a></li>
                                            <?php } ?>
                                            <li><a href="/Users/logout">Logout</a></li>
                                            <li><a href="/tattlraccounts/db">.</a></li> 
                                        </ul>
                                    </div> 
                                </div><!--container-->
                            </div><!--.navbar-inner-->
                        </div><!--navbar-->
                        <div class ="container-fluid2">
                            <div class ="row-fluid">
                                <div></div>
                                <div class ="span2">
                                    <?php echo $this->fetch('content1'); ?>
                                    <?php echo $this->Html->script('jquery-1.4.2.min.js'); ?>
                                    <?php echo $this->Html->script('jquery-ui-1.8.4.custom.min.js'); ?>
                                    <?php echo $this->Html->css('start/jquery-ui-1.8.4.custom.css'); ?>
                                    <head>
                                        <script type="text/javascript">
                                            function displayResult()
                                            {
                                                var phpLogin = document.getElementById("TweetText").value ;
                                                var num = 140 - phpLogin.length;
                                                var link = phpLogin.search("http");
                                                document.getElementById("x").innerHTML = num;
                                                var check = isReply();
                                                document.getElementById("x").style.color = "#268613";
                                                if(num==140){
                                                    document.getElementById("x").style.color = "#E41212";
                                                }
                                                if(num < 0){
                                                    document.getElementById("TweetButton").disabled = true;
                                                    document.getElementById("x").style.color = "#E41212";
                                                }
                                                else{
                                                    if(check == true){
                                                        $('#CancelReply').show(500);
                                                        var empty = CheckReply();
                                                        document.getElementById("TweetButton").disabled = true;
                                                        if(empty == true){
                                                            document.getElementById("TweetButton").disabled = false;
                                                        }
                                                    }else{
                                                        document.getElementById("TweetButton").disabled = true;
                                                        for(var i = 0;i < phpLogin.length;i++){
                                                            if(phpLogin.charAt(i)!=" "){
                                                                document.getElementById("TweetButton").disabled = false;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                                if(link > -1){
                                                    document.getElementById("TweetButton").disabled = false;
                                                }           
                                            }

                                        </script>

                                        <script type="text/javascript">

                                            $(function(){

                                                // Datepicker
                                                $('#datepicker').datepicker({
                                                    inline: true
                                                });

                                            });

                                            $(function(){

                                                // Datepicker
                                                $('#datepicker1').datepicker({
                                                    inline: true
                                                });

                                            });


                                        </script>



                                    </head>

                                    </head>
                                    <br />
                                    <style type="text/css">
                                        .tweetbox{
                                            resize: none;
                                            font-size: 12px;
                                            height: 60px;
                                            border-radius:6px;
                                            border:3px solid #b8b8b8;
                                            width:280px;
                                        }
                                    </style>

                                    <?php
                                    // echo $this->Form->create();
                                    $url = $this->Html->Url(array('controller' => 'Events', 'action' => 'AddTweetLayout'));
                                    echo $this->Form->create('Event', array('action' => 'AddTweetLayout'));

                                    echo $this->Form->input('Tweet', array("cols" => 5, "id" => "TweetText", "placeholder" => "Compose new Tweet...", "class" => "tweetbox", "onkeydown" => "displayResult('" . '' . "')", "onkeyup" => "displayResult()", "onselect" => "displayResult()", "onchange" => "displayResult()", 'style' => 'width:200px'));
                                    echo $this->Form->button('140', array('id' => 'x', 'class' => 'number', 'value' => '140', 'disabled' => 'disabled'));

                                    echo $this->Form->input('Repeated', array('type' => 'checkbox', 'style' => 'width:50px'));

                                    echo $this->Form->input('ForceDeleteMode', array('type' => 'checkbox', 'style' => 'width:50px'));
                                    ?>

                                    <h4> Start Date </h4>

                                    <?php
                                    echo $this->Form->input('Start Date', array('type' => 'text',
                                        'id' => 'datepicker', 'style' => 'width:150px'));


                                    echo $this->Form->input('Clock1 (hh:mm)', array('style' => 'width:150px'));

                                    echo $this->Form->input('End Date', array('type' => 'text',
                                        'id' => 'datepicker1', 'style' => 'width:150px'));
                                    ?>


                                    <h4> Repetitions </h4>

                                    <?php
                                    echo $this->Form->input('NumberOfRepetitions', array('type' => 'integer', 'style' => 'width:150px'));
                                    echo $this->Form->input('MaxNoOfRepetitionsPerDay', array('type' => 'integer', 'style' => 'width:150px'));

                                    echo $this->Form->end('Tweet');
                                    ?>
                                </div><!--span3-->

                                <div class="span6">
                                    <div id = "Test" class = "Notification" ></div>

                                    <?php echo $this->Session->flash(); ?>
                                    <?php echo $this->Session->flash('auth'); ?>
                                    <?php echo $this->fetch('content'); ?>
                                    <?php echo $this->fetch('content2'); ?>
                                    <?php echo $this->fetch('content3'); ?>

                                </div><!--span6-->

                                <div class="span3 offset4">
                                    <div class="well pull-right">
                                        <ul class="nav nav-list">
                                            <li class="nav-header">
                                                Filters
                                            </li>
                                            <li><?php echo $this->Html->link('Filter tweets by date', array('controller' => 'Posts', 'action' => 'filter')); ?></li>
                                            <li><?php echo $this->Html->link('Filter tweets by User', array('controller' => 'Users', 'action' => 'viewUsers')); ?></li>
                                            <li><?php echo $this->Html->link('Filter mentions by date', array('controller' => 'Posts', 'action' => 'filtermentions')); ?></li>
                                            <li><?php echo $this->Html->link('Filter by account', array('controller' => 'Accounts', 'action' => 'filteraccount')); ?></li>
                                            <li><?php echo $this->Html->link('search tweets by text', array('controller' => 'Posts', 'action' => 'search')); ?></li>
                                            <li><?php echo $this->Html->link('Filter DMs by account', array('controller' => 'Accounts', 'action' => 'viewClients')); ?></li>
                                            <li class="nav-header">
                                                Accounts
                                            </li><?php for ($i = 0; $i < count($accounts); $i++) { ?>  <?php
                                        echo $this->Form->create('tattlrAccount', array('action' => 'selectAccount'));
                                        echo $this->Form->hidden('Account', array('value' => $accounts[$i]));
                                        echo $this->Form->submit($images[$i]) . "" . $accounts[$i];
                                        echo $this->Form->end();
                                        ?>  <?php
                                        }
                                    ?>
                                        </ul>
                                    </div>
                                </div><!--span3-->
                            </div><!--row-->
                        </div>
                        <script type="text/javascript">
                            $(document).ready(function() {
                                $.ajaxSetup({
                                    cache: true
                                });

                                //Loading Image.
                                var ajax_load = "<img src='http://d2o0t5hpnwv4c1.cloudfront.net/412_ajaxCalls/DEMO/img/load.gif' alt='loading...' style='top:48%; left:48%; position:relative;'/>";

                                //PHP file URL.
                                var loadUrl = "/Posts/index";
                                var loadUrl2 = "/Posts/fetchHome";
                                var loadUrl3 = "/accounts/getFollowers";
 
                                $(document).on("click", "#dash", function(){ 
                                    $(".container-fluid2").html(ajax_load);  
                                    $.get(  
                                    loadUrl,  
                                    {language: "php", version: 5},  
                                    function(responseText){  
                                        $(".container-fluid2").html(responseText);
                                        $("#CancelReply").hide();
                                        history.replaceState(null, "Dashboard", "/posts");
                                        $(document).attr('title','Dashboard');
                                    },  
                                    "html"  
                                ); 
                                });
                                $(document).on("click", "#home", function(){ 
                                    $(".container-fluid2").html(ajax_load);  
                                    $.get(  
                                    loadUrl2,
                                    {language: "php", version: 5},  
                                    function(responseText){  
                                        $(".container-fluid2").html(responseText);
                                        $("#CancelReply").hide();
                                        history.replaceState(null, "Timeline", "/posts/fetchHome");
                                        $(document).attr('title','Timeline');
                                    },  
                                    "html"  
                                );  
                                });  
                                $(document).on("click", "#followers", function(){
                                    $(".container-fluid2").html(ajax_load);  
                                    $.get(  
                                    loadUrl3,  
                                    {language: "php", version: 5},  
                                    function(responseText){  
                                        $(".container-fluid2").html(responseText); 
                                        $("#CancelReply").hide();
                                        history.replaceState(null, "View followers", "/accounts/getFollowers");
                                        $(document).attr('title','Followers');
                                    },  
                                    "html"  
                                );  
                                });  
                            });  
                        </script>
                    </body>
                    <footer>
                        <?php echo $this->element('sql_dump'); ?>
                    </footer>
                    </html>
